﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using RainEngine.Effects;
using RainEngine.Rendering;
using RainEngine.SceneManagement;

namespace RainEngine.SceneNodes
{
    /// <summary>
    /// PlaneSceneNode是一个由两个三角形构成的简单平面。    
    /// </summary>
    public class PlaneSceneNode:GenericSceneNode 
    {        
        
        /// <summary>
        /// 创建一个默认平面，不使用细节纹理。        
        /// </summary>
        /// <param name="engine">引擎</param>
        /// <param name="setScene">所属场景</param>        
        /// <param name="setDiffuseTextureName">漫反射纹理名称</param>
        public PlaneSceneNode(GraphicsDevice graphicsDevice, ContentManager setContent, Scene setScene, string diffuseTextureName) : this(graphicsDevice, setContent, setScene, diffuseTextureName, null) { }

        /// <summary>
        /// 创建一个拥有颜色纹理和细节纹理的平面。        
        /// </summary>
        /// <param name="engine">引擎</param>
        /// <param name="setScene">所属场景</param>        
        /// <param name="setDiffuseTextureName">漫反射纹理名称</param>
        /// <param name="setDiffuseUVTiles">漫反射纹理UV重复次数</param>
        /// <param name="setDetailTextureName">细节纹理名称</param>
        /// <param name="setDetailTiles">细节纹理UV重复次数</param>
        /// <param name="setDiffuseColor">漫反射颜色</param>
        public PlaneSceneNode(GraphicsDevice graphicsDevice, ContentManager setContent, Scene setScene, string setDiffuseTextureName,string setDetailTextureName)
            : base(graphicsDevice, setContent, setScene, setDiffuseTextureName, setDetailTextureName)
        {
            
        }

        /// <summary>
        /// 初始化QuadSceneNode对象。注意不要使用Initialize方法，它是由引擎调用的。 
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            //创建平面顶点和索引数据
            this.mesh = MeshBuilder.CreatePlane(graphicsDevice);
        }
    }
}
